package com.server.modules.api.web;

import com.server.modules.api.Base.BaseAppController;
import com.server.modules.api.service.GpsAPIService;
import com.server.modules.api.vo.GpsVo;
import com.server.modules.sys.entity.gps.Gps;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * Author Administrator
 * Date 2016/7/26
 */
@Controller
@RequestMapping(value = "/api/gps")
public class GpsAPIController extends BaseAppController {



	@ResponseBody
	@RequestMapping(value = "/uploadGps", method = RequestMethod.POST)
	public GpsVo uploadGps(HttpServletRequest request, Gps gps){
		GpsVo<Gps> vo = new GpsVo<Gps>();
		if(StringUtils.isEmpty(gps.getMemberId()) || StringUtils.isEmpty(gps.getLatitude()) || StringUtils.isEmpty(gps.getLongitude())){
			vo.setRetCode(100);
			vo.setRetMsg("参数错误");
			return vo;
		}
		gps = gpsAPIService.insertGps(gps);
		if(gps == null){
			vo.setRetCode(120);
			vo.setRetMsg("GPS信息上传失败");
		}
		else{
			vo.setRetCode(0);
			vo.setRetMsg("GPS信息上传成功");
			vo.setData(gps);
		}

		return vo;
	}
}
